import pytest
from selenium import webdriver
from utils.log_ import setup_logger
logger = setup_logger(__name__)
_driver = None



# 这里我设置的级别是模块级别，也就是每个测试文件运行一次
@pytest.fixture(scope='module')
def driver():
    global _driver
    print('------------open browser------------')
    options = webdriver.ChromeOptions()
    options.add_experimental_option("excludeSwitches", ['enable-automation', 'load-extension'])  # 屏蔽自动化受控提示 && 开发者提示
    options.add_argument("--start-maximized")  # 浏览器启动时窗口最大化
    options.add_experimental_option("prefs", {"credentials_enable_service": False,
                                              "profile.password_manager_enabled": False})
    _driver = webdriver.Chrome(options=options)
    yield _driver
    print('------------close browser------------')
    _driver.quit()
